package com.lk.utils;

import java.util.List;

/**
 * 分页pojo
 *
 * @param <E>
 */
public class PageList<E> {
    private Integer totalCount;
    private Integer totalPageNum;
    private QueryCondition condition;
    private List<E> dataList;

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
        float nrOfPages = ((float) totalCount) / condition.getPageSize();
        setTotalPageNum((int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
    }

    public Integer getTotalPageNum() {
        return totalPageNum;
    }

    public void setTotalPageNum(Integer totalPageNum) {
        this.totalPageNum = totalPageNum;
    }

    public QueryCondition getCondition() {
        return condition;
    }

    public void setCondition(QueryCondition condition) {
        condition.setStartIndex((condition.getCurrPage() - 1) * condition.getPageSize());
        this.condition = condition;
    }

    public List<E> getDataList() {
        return dataList;
    }

    public void setDataList(List<E> dataList) {
        this.dataList = dataList;
    }

}
